<?php
/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

require_once 'database.php';

class search_handler extends database{
	public $usr_owner;
    public $img_url;
    public $photo_id;
    public $nama;
    public $username;

    function  __construct() {
        parent::__construct();
    }

    function  __destruct() {

    }

    function search_photo($keyword){
        //cari di tag dan description
        
        //tag
        $q = "SELECT * FROM photo WHERE tag REGEXP '$keyword' OR description REGEXP '$keyword'";
        $this->exec_q($q, "url");
        $tmp = $this->result;
        $this->exec_q($q, "photo_id");
        $tmp2 = $this->result;
        $this->exec_q($q, "usr_owner");
        $tmp3 = $this->result;
		
        $this->img_url = $tmp;
        $this->photo_id = $tmp2;
		$this->usr_owner = $tmp3;
        
    }
    
    function search_user($keyword){
        $q = "SELECT usr_email,nama_lengkap FROM user WHERE nama_lengkap like '%$keyword%' ORDER BY usr_email ASC";
        $this->exec_q($q, "usr_email");
        $usr = $this->result;
        $this->exec_q($q, "nama_lengkap");
        $nama_l = $this->result;

        $this->username = $usr;
        $this->nama = $nama_l;
    }

}
?>